<?php if (!defined('BASEPATH')) exit('Access Deny.');
function load_class($classname)
{
    $path_separator = str_replace('_', '/', $classname);
    foreach(array(INCPATH, APPPATH) as $path)
    {
        $realpath = $path . '/' . strtolower($path_separator) . EXT;
        if (is_file($realpath))
        {
            require_once($realpath);
        }
    }
}

function &load_config($filename)
{
    static $_configs;
    
    $filename = strtolower($filename);
    if (isset($_configs[$filename]))
    {
        return $_configs[$filename];
    }
    
    $filepath = CFGPATH . '/' . $filename .EXT;
    
    if (is_file($filepath))
    {
        include_once($filepath);
        if (!isset(${$filename}))
        {
            throw new Exception('Need a Database Settings.');
        }
        
        $_configs[$filename] = ${$filename};
    }
    
    return $_configs[$filename];
}